package com.googlecode.afdbaccess.web.common.util;

import javax.servlet.http.HttpServletRequest;

import com.googlecode.afdbaccess.web.common.exception.GuiLayerException;
import com.googlecode.afdbaccess.web.common.exception.GuiLayerPageNotFoundException;

public class IncludeChecker {
    public static void demandIncluded(HttpServletRequest request) throws GuiLayerException {
        if(request.getAttribute("javax.servlet.include.request_uri") == null && request.getAttribute("javax.servlet.forward.request_uri") == null) {
            throw new GuiLayerPageNotFoundException("This page is not directly callable. It may only be called with jsp:include or jsp:forward.");
        }
    }
}
